package com.alks.function.mapper.photo;

import com.alks.entity.data.entity.PcPhoto;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mapstruct.Mapper;

import java.io.InputStream;
import java.util.List;

@Mapper
public interface PhotoMapping {
    @Select("SELECT  STYLE,COLOR,PHOTO_PATH FROM PC_STYLE_PHOTO WHERE PHOTO_PATH IS NOT NULL")
    List<PcPhoto> getPhoto();

    @Select("SELECT STYLE,COLOR FROM PC_STYLE WHERE PHOTO_PATH IS  NULL AND STYLE_PHOTO IS NOT NULL ")
    List<PcPhoto> getPathNullPhoto();

    @Update("UPDATE PC_STYLE_PHOTO SET PHOTO_PATH = #{photoPath} WHERE STYLE = #{style} AND COLOR = #{color} ")
    void updatePhotoPath(PcPhoto pcPhoto);

    @Select("SELECT STYLE_PHOTO FROM PC_STYLE WHERE STYLE = #{style} AND COLOR = #{color} ")
    InputStream getPhotoStream(PcPhoto photo);
}
